package com.example.weather_forecast;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

// 确保 BaseWeatherFragment 继承自 Fragment 或者包含 onCreateView 方法的类
public class FiveDayForecastFragment extends BaseWeatherFragment {

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    protected void loadData() {
        // 模拟加载5天预报数据
        showLoading();
        // 这里可以添加实际的网络请求逻辑来获取5天预报数据
        // 为了演示，我们创建一些假数据
        List<WeatherData> fiveDayData = new ArrayList<>();
        // 模拟添加5天的数据
        for (int i = 0; i < 5; i++) {
            WeatherData data = new WeatherData("北京市", new Date(), "ic_sunny", "25°C", "20°C~30°C", "晴天");
            fiveDayData.add(data);
        }
        // 模拟网络请求延迟
        new android.os.Handler().postDelayed(() -> {
            showData(fiveDayData);
        }, 2000);
    }
}